Blanket rename rustc-macro to proc-macro
authorAlex Crichton <alex@alexcrichton.com>
Tue, 4 Oct 2016 16:58:28 +0000 (09:58 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 6 Oct 2016 18:09:05 +0000 (11:09 -0700)
src/cargo/core/manifest.rs
src/cargo/util/toml.rs
src/doc/manifest.md
tests/proc-macro.rs [new file with mode: 0644]
tests/rustc-macro.rs [deleted file]

index 827008b8be4b190389853766be441bb804c7ee9f..e72674b9602422f2692a7fb86d73a647504290c0 100644 (file)
@@ -61,7 +61,7 @@ pub enum LibKind {
     Lib,
     Rlib,
     Dylib,
-    RustcMacro,
+    ProcMacro,
     Other(String),
 }
 
@@ -71,7 +71,7 @@ impl LibKind {
             "lib" => LibKind::Lib,
             "rlib" => LibKind::Rlib,
             "dylib" => LibKind::Dylib,
-            "rustc-macro" => LibKind::RustcMacro,
+            "procc-macro" => LibKind::ProcMacro,
             s => LibKind::Other(s.to_string()),
         }
     }
@@ -82,7 +82,7 @@ impl LibKind {
             LibKind::Lib => "lib",
             LibKind::Rlib => "rlib",
             LibKind::Dylib => "dylib",
-            LibKind::RustcMacro => "rustc-macro",
+            LibKind::ProcMacro => "proc-macro",
             LibKind::Other(ref s) => s,
         }
     }
@@ -92,7 +92,7 @@ impl LibKind {
             LibKind::Lib |
             LibKind::Rlib |
             LibKind::Dylib |
-            LibKind::RustcMacro => true,
+            LibKind::ProcMacro => true,
             LibKind::Other(..) => false,
         }
     }
index a051a2836b3beae49e0e13d9e3859e1371009aa8..0a9ecd6136c7f3464ec1776ed0170e3249771806 100644 (file)
@@ -905,7 +905,7 @@ struct TomlTarget {
     bench: Option<bool>,
     doc: Option<bool>,
     plugin: Option<bool>,
-    rustc_macro: Option<bool>,
+    proc_macro: Option<bool>,
     harness: Option<bool>,
 }
 
@@ -934,7 +934,7 @@ impl TomlTarget {
             bench: None,
             doc: None,
             plugin: None,
-            rustc_macro: None,
+            proc_macro: None,
             harness: None,
         }
     }
@@ -1017,15 +1017,15 @@ impl TomlTarget {
     fn validate_crate_type(&self) -> CargoResult<()> {
         // Per the Macros 1.1 RFC:
         //
-        // > Initially if a crate is compiled with the rustc-macro crate type
+        // > Initially if a crate is compiled with the proc-macro crate type
         // > (and possibly others) it will forbid exporting any items in the
-        // > crate other than those functions tagged #[rustc_macro_derive] and
+        // > crate other than those functions tagged #[proc_macro_derive] and
         // > those functions must also be placed at the crate root.
         //
         // A plugin requires exporting plugin_registrar so a crate cannot be
         // both at once.
-        if self.plugin == Some(true) && self.rustc_macro == Some(true) {
-            Err(human("lib.plugin and lib.rustc-macro cannot both be true".to_string()))
+        if self.plugin == Some(true) && self.proc_macro == Some(true) {
+            Err(human("lib.plugin and lib.proc-macro cannot both be true".to_string()))
         } else {
             Ok(())
         }
@@ -1064,7 +1064,7 @@ fn normalize(lib: &Option<TomlLibTarget>,
               .set_doctest(toml.doctest.unwrap_or(t2.doctested()))
               .set_benched(toml.bench.unwrap_or(t2.benched()))
               .set_harness(toml.harness.unwrap_or(t2.harness()))
-              .set_for_host(match (toml.plugin, toml.rustc_macro) {
+              .set_for_host(match (toml.plugin, toml.proc_macro) {
                   (None, None) => t2.for_host(),
                   (Some(true), _) | (_, Some(true)) => true,
                   (Some(false), _) | (_, Some(false)) => false,
@@ -1081,7 +1081,7 @@ fn normalize(lib: &Option<TomlLibTarget>,
             Some(kinds) => kinds.iter().map(|s| LibKind::from_str(s)).collect(),
             None => {
                 vec![ if l.plugin == Some(true) {LibKind::Dylib}
-                      else if l.rustc_macro == Some(true) {LibKind::RustcMacro}
+                      else if l.proc_macro == Some(true) {LibKind::ProcMacro}
                       else {LibKind::Lib} ]
             }
         };
index eb5331d54e2dc99c8eb150ea6efe94fbf08803bc..9aaab670738bb15c936cf00d40959d7c79c35915 100644 (file)
@@ -512,7 +512,7 @@ plugin = false
 
 # If the target is meant to be a "macros 1.1" procedural macro, this field must
 # be set to true.
-rustc-macro = false
+proc-macro = false
 
 # If set to false, `cargo test` will omit the `--test` flag to rustc, which
 # stops it from generating a test harness. This is useful when the binary being
@@ -534,11 +534,11 @@ crate-type = ["dylib"] # could be `staticlib` as well
 ```
 
 The available options are `dylib`, `rlib`, `staticlib`, `cdylib`, and
-`rustc-macro`. You should only use this option in a project. Cargo will always
+`proc-macro`. You should only use this option in a project. Cargo will always
 compile packages (dependencies) based on the requirements of the project that
 includes them.
 
-You can read more about the different crate types in the 
+You can read more about the different crate types in the
 [Rust Reference Manual](https://doc.rust-lang.org/reference.html#linkage)
 
 # The `[replace]` Section
diff --git a/tests/proc-macro.rs b/tests/proc-macro.rs
new file mode 100644 (file)
index 0000000..daae388
--- /dev/null
@@ -0,0 +1,190 @@
+extern crate cargotest;
+extern crate hamcrest;
+
+use cargotest::is_nightly;
+use cargotest::support::{project, execs};
+use hamcrest::assert_that;
+
+#[test]
+#[ignore]
+fn noop() {
+    if !is_nightly() {
+        return;
+    }
+
+    let client = project("client")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "client"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies.noop]
+            path = "../noop"
+        "#)
+        .file("src/main.rs", r#"
+            #![feature(proc_macro)]
+
+            #[macro_use]
+            extern crate noop;
+
+            #[derive(Noop)]
+            struct X;
+
+            fn main() {}
+        "#);
+    let noop = project("noop")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "noop"
+            version = "0.0.1"
+            authors = []
+
+            [lib]
+            proc-macro = true
+        "#)
+        .file("src/lib.rs", r#"
+            #![feature(proc_macro, proc_macro_lib)]
+
+            extern crate proc_macro;
+            use proc_macro::TokenStream;
+
+            #[proc_macro_derive(Noop)]
+            pub fn noop(input: TokenStream) -> TokenStream {
+                input
+            }
+        "#);
+    noop.build();
+
+    assert_that(client.cargo_process("build"),
+                execs().with_status(0));
+    assert_that(client.cargo("build"),
+                execs().with_status(0));
+}
+
+#[test]
+#[ignore]
+fn impl_and_derive() {
+    if !is_nightly() {
+        return;
+    }
+
+    let client = project("client")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "client"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies.transmogrify]
+            path = "../transmogrify"
+        "#)
+        .file("src/main.rs", r#"
+            #![feature(proc_macro)]
+
+            #[macro_use]
+            extern crate transmogrify;
+
+            trait ImplByTransmogrify {
+                fn impl_by_transmogrify(&self) -> bool;
+            }
+
+            #[derive(Transmogrify)]
+            struct X;
+
+            fn main() {
+                let x = X::new();
+                assert!(x.impl_by_transmogrify());
+                println!("{:?}", x);
+            }
+        "#);
+    let transmogrify = project("transmogrify")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "transmogrify"
+            version = "0.0.1"
+            authors = []
+
+            [lib]
+            proc-macro = true
+        "#)
+        .file("src/lib.rs", r#"
+            #![feature(proc_macro, proc_macro_lib)]
+
+            extern crate proc_macro;
+            use proc_macro::TokenStream;
+
+            #[proc_macro_derive(Transmogrify)]
+            #[doc(hidden)]
+            pub fn transmogrify(input: TokenStream) -> TokenStream {
+                assert_eq!(input.to_string(), "struct X;\n");
+
+                "
+                    impl X {
+                        fn new() -> Self {
+                            X { success: true }
+                        }
+                    }
+
+                    impl ImplByTransmogrify for X {
+                        fn impl_by_transmogrify(&self) -> bool {
+                            true
+                        }
+                    }
+
+                    #[derive(Debug)]
+                    struct X {
+                        success: bool,
+                    }
+                ".parse().unwrap()
+            }
+        "#);
+    transmogrify.build();
+
+    assert_that(client.cargo_process("build"),
+                execs().with_status(0));
+    assert_that(client.cargo("run"),
+                execs().with_status(0).with_stdout("X { success: true }"));
+}
+
+#[test]
+#[ignore]
+fn plugin_and_proc_macro() {
+    if !is_nightly() {
+        return;
+    }
+
+    let questionable = project("questionable")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "questionable"
+            version = "0.0.1"
+            authors = []
+
+            [lib]
+            plugin = true
+            proc-macro = true
+        "#)
+        .file("src/lib.rs", r#"
+            #![feature(plugin_registrar, rustc_private)]
+            #![feature(proc_macro, proc_macro_lib)]
+
+            extern crate rustc_plugin;
+            use rustc_plugin::Registry;
+
+            extern crate proc_macro;
+            use proc_macro::TokenStream;
+
+            #[plugin_registrar]
+            pub fn plugin_registrar(reg: &mut Registry) {}
+
+            #[proc_macro_derive(Questionable)]
+            pub fn questionable(input: TokenStream) -> TokenStream {
+                input
+            }
+        "#);
+
+    let msg = "  lib.plugin and lib.proc-macro cannot both be true";
+    assert_that(questionable.cargo_process("build"),
+                execs().with_status(101).with_stderr_contains(msg));
+}
diff --git a/tests/rustc-macro.rs b/tests/rustc-macro.rs
deleted file mode 100644 (file)
index f9ea79d..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-extern crate cargotest;
-extern crate hamcrest;
-
-use cargotest::is_nightly;
-use cargotest::support::{project, execs};
-use hamcrest::assert_that;
-
-#[test]
-#[ignore]
-fn noop() {
-    if !is_nightly() {
-        return;
-    }
-
-    let client = project("client")
-        .file("Cargo.toml", r#"
-            [package]
-            name = "client"
-            version = "0.0.1"
-            authors = []
-
-            [dependencies.noop]
-            path = "../noop"
-        "#)
-        .file("src/main.rs", r#"
-            #![feature(rustc_macro)]
-
-            #[macro_use]
-            extern crate noop;
-
-            #[derive(Noop)]
-            struct X;
-
-            fn main() {}
-        "#);
-    let noop = project("noop")
-        .file("Cargo.toml", r#"
-            [package]
-            name = "noop"
-            version = "0.0.1"
-            authors = []
-
-            [lib]
-            rustc-macro = true
-        "#)
-        .file("src/lib.rs", r#"
-            #![feature(rustc_macro, rustc_macro_lib)]
-
-            extern crate rustc_macro;
-            use rustc_macro::TokenStream;
-
-            #[rustc_macro_derive(Noop)]
-            pub fn noop(input: TokenStream) -> TokenStream {
-                input
-            }
-        "#);
-    noop.build();
-
-    assert_that(client.cargo_process("build"),
-                execs().with_status(0));
-    assert_that(client.cargo("build"),
-                execs().with_status(0));
-}
-
-#[test]
-#[ignore]
-fn impl_and_derive() {
-    if !is_nightly() {
-        return;
-    }
-
-    let client = project("client")
-        .file("Cargo.toml", r#"
-            [package]
-            name = "client"
-            version = "0.0.1"
-            authors = []
-
-            [dependencies.transmogrify]
-            path = "../transmogrify"
-        "#)
-        .file("src/main.rs", r#"
-            #![feature(rustc_macro)]
-
-            #[macro_use]
-            extern crate transmogrify;
-
-            trait ImplByTransmogrify {
-                fn impl_by_transmogrify(&self) -> bool;
-            }
-
-            #[derive(Transmogrify)]
-            struct X;
-
-            fn main() {
-                let x = X::new();
-                assert!(x.impl_by_transmogrify());
-                println!("{:?}", x);
-            }
-        "#);
-    let transmogrify = project("transmogrify")
-        .file("Cargo.toml", r#"
-            [package]
-            name = "transmogrify"
-            version = "0.0.1"
-            authors = []
-
-            [lib]
-            rustc-macro = true
-        "#)
-        .file("src/lib.rs", r#"
-            #![feature(rustc_macro, rustc_macro_lib)]
-
-            extern crate rustc_macro;
-            use rustc_macro::TokenStream;
-
-            #[rustc_macro_derive(Transmogrify)]
-            #[doc(hidden)]
-            pub fn transmogrify(input: TokenStream) -> TokenStream {
-                assert_eq!(input.to_string(), "struct X;\n");
-
-                "
-                    impl X {
-                        fn new() -> Self {
-                            X { success: true }
-                        }
-                    }
-
-                    impl ImplByTransmogrify for X {
-                        fn impl_by_transmogrify(&self) -> bool {
-                            true
-                        }
-                    }
-
-                    #[derive(Debug)]
-                    struct X {
-                        success: bool,
-                    }
-                ".parse().unwrap()
-            }
-        "#);
-    transmogrify.build();
-
-    assert_that(client.cargo_process("build"),
-                execs().with_status(0));
-    assert_that(client.cargo("run"),
-                execs().with_status(0).with_stdout("X { success: true }"));
-}
-
-#[test]
-#[ignore]
-fn plugin_and_rustc_macro() {
-    if !is_nightly() {
-        return;
-    }
-
-    let questionable = project("questionable")
-        .file("Cargo.toml", r#"
-            [package]
-            name = "questionable"
-            version = "0.0.1"
-            authors = []
-
-            [lib]
-            plugin = true
-            rustc-macro = true
-        "#)
-        .file("src/lib.rs", r#"
-            #![feature(plugin_registrar, rustc_private)]
-            #![feature(rustc_macro, rustc_macro_lib)]
-
-            extern crate rustc_plugin;
-            use rustc_plugin::Registry;
-
-            extern crate rustc_macro;
-            use rustc_macro::TokenStream;
-
-            #[plugin_registrar]
-            pub fn plugin_registrar(reg: &mut Registry) {}
-
-            #[rustc_macro_derive(Questionable)]
-            pub fn questionable(input: TokenStream) -> TokenStream {
-                input
-            }
-        "#);
-
-    let msg = "  lib.plugin and lib.rustc-macro cannot both be true";
-    assert_that(questionable.cargo_process("build"),
-                execs().with_status(101).with_stderr_contains(msg));
-}